package leetcode;

/**
 * @author Liangyaoyun
 */
public class leetCode101 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
    public boolean BST(TreeNode left,TreeNode right){
        if(left==null && right==null) {
            return true;
        }
        if(left==null || right==null) {
            return false;
        }
        if(left.val!=right.val) {
            return false;
        }
        return BST(left.left,right.right)&&BST(left.right,right.left);
    }
    public boolean isSymmetric(TreeNode root) {
        TreeNode left=root.left;
        TreeNode right=root.right;
        if (left!=null&&right!=null){
            return BST(left,right);
        }
        else if (left==null&&right==null){
            return true;
        }else {
            return false;
        }
    }

    public static void main(String[] args) {
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(2);
        TreeNode treeNode3=new TreeNode(2);
        TreeNode treeNode4=new TreeNode();
        TreeNode treeNode5=new TreeNode(3);
        TreeNode treeNode6=new TreeNode();
        TreeNode treeNode7=new TreeNode(3);

        TreeNode root1=new TreeNode(1,treeNode2,treeNode3);
        TreeNode root2=new TreeNode(2,treeNode4,treeNode5);
        TreeNode root3=new TreeNode(2,treeNode6,treeNode7);
        TreeNode root=new TreeNode(1,root2,root3);

    }
}
